﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="Bookmark" href="/favicon.ico">
    <link rel="Shortcut Icon" href="/favicon.ico"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__STATIC__/admin/lib/html5shiv.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__STATIC__/admin/static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/admin/static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/admin/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/admin/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/admin/static/h-ui.admin/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/admin/static/h-ui.admin/css/page.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="__STATIC__/admin/lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>分类列表</title>
    <style>
        .padding-l{
            padding-left: 20% !important;
        }
        .font-w{
            font-weight: bold !important;
        }
    </style>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    首页 <span class="c-gray en">&gt;</span>
    分类管理 <span class="c-gray en">&gt;</span>
    分类列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <div class="row cl mb-20">
        <div class="col-xs-6 text-l">
            <a href="javascript:;" onclick="cateAdd(0,1,'顶级分类')" class="btn btn-primary radius">
                <i class="Hui-iconfont">&#xe600;</i> 新增分类</a>
        </div>
    </div>
    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr class="text-c">
            <th width="30">ID</th>
            <th width="100">分类名称</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo"}
        <tr class="text-c">
            <td>{$vo.cate_id}</td>
            <td class="text-l padding-l font-w">{$vo.cate_name}</td>
            <td class="td-cate">
                <a title="新增子分类" style="text-decoration:none" onClick="cateAdd({$vo.cate_id},2,'{$vo.cate_name}')" href="javascript:;" >
                    <i class="Hui-iconfont">&#xe600;</i></a>
                <a title="编辑" href="javascript:;" onclick="cateUpd(0,1,'顶级分类',{$vo.cate_id})" class="ml-5"
                   style="text-decoration:none">
                    <i class="Hui-iconfont">&#xe6df;</i></a>
                <a title="删除" href="javascript:;" onclick="cateDel({$vo.cate_id})" class="ml-5"
                   style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
            </td>
        </tr>
        {present name="$vo.children"}
            {volist name="$vo.children" id="children"}
            <tr class="text-c">
                <td>{$children.cate_id}</td>
                <td class="text-l padding-l">{$children.cate_name}</td>
                <td class="td-cate">
                    <a title="编辑" href="javascript:;" onclick="cateUpd({$vo.cate_id},2,'{$vo.cate_name}',{$children.cate_id})" class="ml-5"
                       style="text-decoration:none">
                        <i class="Hui-iconfont">&#xe6df;</i></a>
                    <a title="删除" href="javascript:;" onclick="cateDel({$children.cate_id})" class="ml-5"
                       style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                </td>
            </tr>
            {/volist}
        {/present}
        {/volist}
        </tbody>
    </table>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__STATIC__/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__STATIC__/admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
    /*分类-增加*/
    function cateAdd(pid,level,level_name) {
        var title = "分类新增";
        var url = "{:url('cate/add')}?pid="+pid+"&level="+level+"&level_name="+level_name;
        var w = 800;
        var h = 300;
        layer_show(title, url, w, h);
    }

    /*分类-编辑*/
    function cateUpd(pid,level,level_name,cate_id) {
        var title = "分类编辑";
        var url = "{:url('cate/upd')}?pid="+pid+"&level="+level+"&level_name="+level_name+"&cate_id="+cate_id;
        var w = 800;
        var h = 300;
        layer_show(title, url, w, h);
    }

    /*分类-删除*/
    function cateDel(cate_id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: '{:url("cate/del")}',
                data: {
                    cate_id: cate_id
                },
                dataType: 'json',
                success: function (res) {
                    if (res.code == 1) {
                        layer.alert(res.message);
                    }
                    if (res.code == 0) {
                        location.reload();//刷新
                    }
                },
                error: function () {
                    console.log("异常");
                }
            });
        });
    }
</script>
</body>
</html>